package com.zdp.provider.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.zdp.provider.service.CourseService;
import com.zdp.provider.service.CourseServiceFallBackImp;
import com.zdp.provider.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * 类描述: 教师信息服务
 *
 * @author ZhhengDP
 * @since 2021/8/16
 */
@RestController
@RequestMapping("/teacher_info")
public class TeacherController {


    private TeacherService teacherService;

    private CourseService courseService;


    @Autowired
    public TeacherController(TeacherService teacherService,
                             CourseService courseService
                             ) {
        this.teacherService = teacherService;
        this.courseService = courseService;

    }

    @GetMapping("/teacher")
    public TeacherVo getTeacher(Integer teacherId){
        TeacherVo teacher = teacherService.getTeacherById(teacherId);
        List<CourseDto> courses = courseService.getCourses(teacherId);
        teacher.setCourses(courses);
        return teacher;
    }






}
